﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MvvmHelper;
using System.Windows;
using System.Windows.Data;
using System.Windows.Input;
using System.ComponentModel;
using Model;
using IDAL;
using DAL_Stab;

namespace WpfApplication1
{
    class ViewModel : UCTVM ,INotifyPropertyChanged
    {
        new public event PropertyChangedEventHandler PropertyChanged; //プロパティチェンジ用ハンド
        private static readonly IUser dal = new User();
        public ViewModel()
        {
            this.JOBNAME = "HHT切り替えデータ参照";
            IList<UserInfo> UserList = dal.GetEntityList();
            this.User = "ユーザーID:" + UserList[0].strユーザーID + "\r\nユーザー名" + UserList[0].strユーザー名;
            this.Shop2 = this.JOBNAME;
        }
        #region JOBNAME

        public String JOBNAME
        {
            get { return _JOBNAME; }
            set
            {
                _JOBNAME = value;
                PropertyChanged.Raise(this, JOBNAMEName);
            }
        }

        private String _JOBNAME;
        internal static readonly string JOBNAMEName = PropertyName<ViewModel>.Get(_ => _.JOBNAME);
        #endregion
        
        
        
        #region User



        public String User
        {
            get { return _User; }
            set
            {
                _User = value;
                this.PropertyChanged.Raise(this, UserName);
            }
        }

        private String _User;
        internal static readonly string UserName = PropertyName<ViewModel>.Get(_ => _.User);

        #endregion

        #region colHHTDATA

        public List<HHTConvData> colHHTDATA
        {
            get { return _colHHTDATA; }
            set
            {
                _colHHTDATA = value;
                PropertyChanged.Raise(this, colHHTDATAName);
            }
        }

        private List<HHTConvData> _colHHTDATA;
        internal static readonly string colHHTDATAName = PropertyName<ViewModel>.Get(_ => _.colHHTDATA);

        #endregion
        #region SearchCommand

        private void SearchCommandHandler(object parameter)
        {
            string Temp = this.Input;
            List<HHTConvData> LocalList = new List<HHTConvData>();
            for (int i = 0; i < 100; i++)
            {
                LocalList.Add(new HHTConvData()
                {
                    int通番 = i,
                    flg入力確定画面遷移 = true,
                    int登録状態 = 0,
                    strHHT番号 = "12345",
                    Dateアップデート日時 = DateTime.Today,
                    intロット番号 = 4,
                    int入力種別 = 1,
                    int値上下区分 = 0,
                    str旧売場 = "12345",
                    str新売場 = "54321",
                    str取引先コード = "88888",
                    str取引先名称 = "SFI",
                    dec旧原価金額合計 = 30000,
                    dec新原価金額合計 = 50000,
                    dec旧売価金額合計 = 40000,
                    dec新売価金額合計 = 80000,
                    str入力者 = "12345",
                    str入力者名 = "SFI太郎",
                    int明細数 = 30,
                    intエラー数 = 5,
                    int取消数 = 8
                });
            }
            this.colHHTDATA = LocalList;
        }

        public ICommand SearchCommand
        {
            get
            {
                if (_SearchCommand == null)
                    _SearchCommand = new DelegateCommand { CommandHandler = this.SearchCommandHandler };
                return _SearchCommand;
            }
        }
        private ICommand _SearchCommand;
        

        #endregion
    }
}
